home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Apple Guide / Engineering / RenoDB Library / RenoDBLib.h < prev    next >
Encoding:
Text File  |  1994-08-15  |  6.4 KB  |  251 lines  |  [TEXT/MPS ]

  1. // RenoDBLib.h
  2. //
  3. // Copyright ©1994 Apple Computer, Inc. All rights reserved.
  4. // A POCO Production
  5. // 15-Aug-94
  6. //
  7. // A C interface to the RenoDB library.
  8. //
  9. // Also see the AGFile library which provides access
  10. // to information about the guide file.
  11.  
  12.  
  13. //    The AGDBRefNum structure is used by the RenoDBLib C Glue to perform its stuff.
  14. //    It should not be modified in any way.
  15.  
  16. struct AGDBRefNum    
  17. {
  18.     unsigned long    dbRefRes;
  19.     unsigned long    dbRefIndex;
  20.     short            flags;
  21. } AGDBRefNum;
  22.  
  23. //
  24. // --------- General RenoDB structures --------------
  25. //
  26.  
  27. struct ResData
  28. {
  29.     unsigned short        resID;
  30.     OSType                resType;
  31.     unsigned short        keyAttributes;
  32. };
  33.  
  34. struct Reference
  35. {
  36.     unsigned short        resID;
  37.     OSType                resType;
  38.     unsigned short        keyAttributes;
  39.     short                resFileIndex;
  40. };
  41.  
  42. struct KeyRef
  43. {
  44.     unsigned char    *key;    // Pascal string
  45.     Reference        ref;
  46. };
  47.  
  48. struct TReferenceList
  49. {
  50.     enum            { kNoOrder, kAscending, kDescending, kRandom };
  51.     OSErr            result;
  52.     int                size;
  53.     int                limit;
  54.     int                listOrder;
  55.     char            isCompact;
  56.     unsigned char    *keyBuffer;
  57.     KeyRef            **list;
  58.     KeyRef            lastKeyDropped;
  59.     Handle            itl2Hand;
  60.     short            fFastUSASCIIDB;
  61.     short            fDBScript;
  62.     unsigned long    fCompareCount;
  63. };
  64.  
  65. typedef OSType DBScopeType;
  66.  
  67. //
  68. // --------- Phrase reduction information --------------
  69. //
  70.  
  71. struct wordElement {
  72.     unsigned char    processResult;        // kStopListEntry, kThesaurusEntry, kStemmed
  73.     short            occurenceCount;        // number of finds in the db
  74.     OffPair            bufferOffsets;        // where the word began and ended in the buffer
  75.     OffPair            destOffsets;        // where the word began and ended in destination
  76. };
  77.  
  78. struct LookForRec {
  79.     short        phraseWords;            // The number of words in the original phrase
  80.     short        phraseOccurenceCount;    // The number of finds for the whole phrase
  81.     wordElement    word[1];                // The first element of the list - more can follow
  82. };
  83.  
  84. typedef LookForRec    *LookForPtr, **LookForHand;
  85.  
  86. //
  87. // --------- Primary functions to open and close the guide file --------------
  88. //
  89.  
  90. //                DBNew creates new files & opens them
  91. OSErr
  92. DBNew( AGDBRefNum* dbRefNum, FSSpec* theFile );
  93.  
  94. //                DBNewRW creates new files & opens them for authoring
  95. OSErr
  96. DBNewRW( AGDBRefNum* dbRefNum, FSSpec* theFile );
  97.  
  98. //                DBOpen opens file
  99. OSErr
  100. DBOpen( AGDBRefNum* dbRefNum, FSSpec* theFile );
  101.  
  102. //                DBOpenRW opens file for authoring
  103. OSErr
  104. DBOpenRW( AGDBRefNum* dbRefNum, FSSpec* theFile );
  105.  
  106. //                DBClose closes file
  107. OSErr    
  108. DBClose( AGDBRefNum* dbRefNum );
  109.  
  110. //
  111. // --------- Functions to access the guide file resource fork --------------
  112. //
  113. //    Functions that access only the resource fork of the open guide file.
  114. //
  115.  
  116. short             DBCount1Types( AGDBRefNum* dbRefNum );
  117. void            DBGetIndType( AGDBRefNum* dbRefNum, ResType* rType, short rIndex );
  118. short            DBCountResources(AGDBRefNum* dbRefNum, ResType rType );
  119. Handle            DBGetIndResource(AGDBRefNum* dbRefNum, ResType rType, short rIndex );
  120. Handle            DBGetResource(AGDBRefNum* dbRefNum, ResType rType, short rID );
  121. Handle            DBGetNamedResource( AGDBRefNum* dbRefNum, ResType rType, unsigned char * rText );
  122. Handle            DBGetPicture( AGDBRefNum* dbRefNum, short pictID );
  123. Handle            DBGetIcon( AGDBRefNum* dbRefNum, short iconID );
  124. void            DBGetIndString( AGDBRefNum* dbRefNum, Str255 theString, short strListID, short index );
  125. ControlHandle    DBGetNewControl( AGDBRefNum* dbRefNum, short controlID, WindowPtr theWindow );
  126. CursHandle        DBGetCursor( AGDBRefNum* dbRefNum, short cursorID );
  127. short            DBUniqueID( AGDBRefNum* dbRefNum, ResType rType );
  128.  
  129.  
  130. //
  131. // --------- Standard guide file read-only functions --------------
  132. //
  133. //    Functions which first access the resource fork and then, if not found,
  134. //    access the data fork.
  135. //
  136.  
  137. Handle
  138. DBGetIUSortResource( AGDBRefNum* dbRefNum );
  139.  
  140. void
  141. DBSetIUSortResource(AGDBRefNum* dbRefNum, Handle theitl2 );
  142.  
  143. short
  144. DBIsFastUSASCIISortDB(AGDBRefNum* dbRefNum);
  145.  
  146. void
  147. DBSetFastUSASCIISortDB(AGDBRefNum* dbRefNum, short newState );
  148.  
  149. long
  150. DBKeyCount(AGDBRefNum* dbRefNum, DBScopeType theScope );
  151.  
  152. long
  153. DBKeyCount(AGDBRefNum* dbRefNum, DBScopeType theScope, const unsigned char* theKey );
  154.  
  155. KeyRef
  156. DBFirstIndex(AGDBRefNum* dbRefNum, DBScopeType theScope );
  157.  
  158. void
  159. DBFirstIndex(AGDBRefNum* dbRefNum, DBScopeType theScope, short maximum, TReferenceList* refList );
  160.  
  161. void
  162. DBNextIndex(AGDBRefNum* dbRefNum, KeyRef* keyRef);
  163.  
  164. void
  165. DBNextIndex(AGDBRefNum* dbRefNum, short maximum, TReferenceList* refList);
  166.  
  167. void
  168. DBLastIndex(AGDBRefNum* dbRefNum, DBScopeType theScope, KeyRef* keyRef);
  169.  
  170. void
  171. DBFindIndex(AGDBRefNum* dbRefNum, DBScopeType theScope,
  172.                     const unsigned char* firstKey, const unsigned char* lastKey,
  173.                     short maximum, TReferenceList* refList);
  174.  
  175. void
  176. DBPreviousIndex(AGDBRefNum* dbRefNum, DBScopeType theScope,
  177.                 const unsigned char* theKey, KeyRef* keyRef);
  178.  
  179. short
  180. DBNumDBFiles( AGDBRefNum* dbRefNum );
  181.  
  182. OSErr
  183. DBGetDBFileInfo( AGDBRefNum* dbRefNum, short index, FSSpec* theDBFile );
  184.  
  185. OSErr
  186. DBReducePhrase( AGDBRefNum* dbRefNum, unsigned char* thePhrase, LookForHand* theInfo );
  187.  
  188. void
  189. DBLookForPhrase(    AGDBRefNum* dbRefNum, DBScopeType theScope,
  190.                     unsigned char* reducedString, LookForHand theInfo,
  191.                     short scopeInData, TReferenceList* refList );
  192.  
  193. short
  194. DBGetDefaultRefNum( AGDBRefNum* dbRefNum );
  195.  
  196. void
  197. DBSetDefaultRefNum( AGDBRefNum* dbRefNum, short newRefNum );
  198.  
  199. Handle
  200. DBGetData( AGDBRefNum* dbRefNum, Reference* foundItem );
  201.  
  202. Handle
  203. DBGetData( AGDBRefNum* dbRefNum, KeyRef* foundItem );
  204.  
  205. short
  206. DBGetDBRefNum( AGDBRefNum* dbRefNum, const short index );
  207.  
  208. //
  209. // --------- Authoring functions (read/write) --------------
  210. //
  211.  
  212. OSErr
  213. DBKeyBetween(        AGDBRefNum* dbRefNum, unsigned char *destKey,
  214.                 unsigned char *firstKey, unsigned char *lastKey );
  215.  
  216. OSErr
  217. DBBuildIncMask(    AGDBRefNum* dbRefNum, unsigned char    *firstKey,
  218.                 unsigned char *lastKey, short divisions, unsigned short *incMask );
  219.  
  220. OSErr
  221. DBIncrementKey( AGDBRefNum* dbRefNum, unsigned char *theKey, unsigned short incMask );
  222.  
  223. OSErr
  224. DBAddIndex(    AGDBRefNum* dbRefNum, Reference* theContent,
  225.             DBScopeType theScope, const unsigned char *theKey );
  226.  
  227. OSErr
  228. DBDeleteIndex(    AGDBRefNum* dbRefNum, Reference* theContent,
  229.                 DBScopeType theScope, const unsigned char *theKey );
  230.  
  231. OSErr
  232. DBLoadDB( AGDBRefNum* dbRefNum, FSSpec* dbFile );
  233.  
  234. OSErr
  235. DBDumpDB( AGDBRefNum* dbRefNum, FSSpec* dbFile, short index );
  236.  
  237. OSErr
  238. DBDumpOneDBResType( AGDBRefNum* dbRefNum, FSSpec* dbFile, OSType onlyOne, short index );
  239.  
  240. OSErr
  241. StoreDataRef( AGDBRefNum* dbRefNum, Reference theKind, Handle theData );
  242.  
  243. OSErr
  244. StoreDataKeyRef( AGDBRefNum* dbRefNum, KeyRef theKind, Handle theData );
  245.  
  246. OSErr
  247. DeleteDataRef( AGDBRefNum* dbRefNum, Reference theContent );
  248.  
  249. OSErr
  250. DeleteDataKeyRef( AGDBRefNum* dbRefNum, KeyRef theContent );
  251.